﻿using System;
using System.Collections.Generic;
using System.Text;

using E.Model;
using E.DAL;
using System.Data;

namespace E.BLL
{
    public class UserBLL
    {
        private UserDAL dal;

        public UserBLL()
        {
            dal = new UserDAL();
        }
        
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ShortUserModel Login(UserModel model)
        {
            return dal.Login(model);
        }

        /// <summary>
        /// 向登陆历史表中加入数据
        /// </summary>
        /// <param name="model"></param>
        public void InsertLoginHistory(UserModel model)
        {
            dal.InsertLoginHistory(model);
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public int UpdatePassword(int userid, string pwd)
        {
            return dal.UpdatePassword(userid, pwd);
        }

        /// <summary>
        /// 修改密码（需要原密码）
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="originalpwd"></param>
        /// <param name="newpwd"></param>
        /// <returns></returns>
        public int UpdatePasswordWithOriginalPwd(int userid, string originalpwd, string newpwd)
        {
            return dal.UpdatePasswordWithOriginalPwd(userid, originalpwd, newpwd);
        }

        /// <summary>
        /// 修改资料
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateUserInfo(UserModel model)
        {
            return dal.UpdateUserInfo(model);
        }

        /// <summary>
        /// 获取用户证书列表
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public IList<UserCertificateLogModel> GetUserCertificateList(int userid)
        {
            return dal.GetUserCertificateList(userid);
        }

        /// <summary>
        /// 获取学习成绩列表
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="courseRelationID"></param>
        /// <param name="examCategoryID"></param>
        /// <returns></returns>
        public IList<ShortUserScoreModel> GetUserScoreList(int userid, int examCategoryID)
        {
            return dal.GetUserScoreList(userid, examCategoryID);
        }

        /// <summary>
        /// 检查登录ID
        /// </summary>
        /// <param name="loginid"></param>
        /// <returns></returns>
        public bool CheckExistLoginID(string loginid)
        {
            return dal.CheckExistLoginID(loginid);
        }

        /// <summary>
        /// 检查身份证
        /// </summary>
        /// <param name="idcard"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public bool CheckExistIDCard(string idcard, int userid)
        {
            return dal.CheckExistIDCard(idcard, userid);
        }

        /// <summary>
        /// 添加学员
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddUser(UserModel model)
        {
            return dal.AddUser(model);
        }

        /// <summary>
        /// 批量添加学员
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddPluralUsers(PluralUserModel model)
        {
            return dal.AddPluralUsers(model);
        }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public UserModel GetUserInfoByUserID(int userid)
        {
            return dal.GetUserInfoByUserID(userid);
        }

        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public ListModel GetUserListByCondition(UserModel model, int pageSize, int pageIndex)
        {
            return dal.GetUserListByCondition(model, pageSize, pageIndex);
        }

        /// <summary>
        /// 获得没有报名制定项目和课程班级的学生
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IList<UserListModel> GetUnSignUpInternalClassUserListByCondition(UserModel model)
        {
            return dal.GetUnSignUpInternalClassUserListByCondition(model);
        }
        /// <summary>
        /// 获得没有报名制定项目和课程班级的外训学生
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IList<UserListModel> GetUnSignUpPublicClassUserListByCondition(UserModel model)
        {
            return dal.GetUnSignUpPublicClassUserListByCondition(model);
        }
        /// <summary>
        /// 激活用户账号
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int ActiveUser(int id)
        {
            return dal.ActiveUser(id);
        }

        /// <summary>
        /// 冻结用户账号
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int FreezeUser(int id)
        {
            return dal.FreezeUser(id);
        }

        /// <summary>
        /// 批量冻结学生
        /// </summary>
        /// <param name="id">学生id用,相隔</param>
        /// <returns></returns>
        public int BatchFreeUser(String id)
        {
            return dal.BatchFreeUser(id);
        }

        #region 学历

        /// <summary>
        /// 学历列表
        /// </summary>
        /// <returns></returns>
        public IDictionary<int, string> GetEducationList()
        {
            return dal.GetEducationList();
        }

        #endregion
        
        #region 忘记密码

        /// <summary>
        /// 
        /// </summary>
        /// <param name="loginid"></param>
        /// <returns></returns>
        public IDictionary<int, string> GetForgetPwdInfoByLoginID(string loginid)
        {
            return dal.GetForgetPwdInfoByLoginID(loginid);
        }

        /// <summary>
        /// 获取用户提示问题
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public PwdQuestionUserModel GetForgetPwdQuestionID(int userid)
        {
            return dal.GetForgetPwdQuestionID(userid);
        }

        /// <summary>
        /// 检查用户忘记密码提示问题答案是否正确
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="answer"></param>
        /// <returns></returns>
        public int CheckForgetPwdAnswer(int userid, string answer)
        {
            return dal.CheckForgetPwdAnswer(userid, answer);
        }

        /// <summary>
        /// 获取忘记密码提示问题列表
        /// </summary>
        /// <returns></returns>
        public IDictionary<int, string> GetForgetPwdQuestionList()
        {
            return dal.GetForgetPwdQuestionList();
        }

        /// <summary>
        /// 更新安全信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateFortgetPwdInfo(PwdQuestionUserModel model)
        {
            return dal.UpdateFortgetPwdInfo(model);
        }

        #endregion

        #region 内训

        /// <summary>
        /// 获取用户项目组ID
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public int GetUserProjectID(int userid)
        {
            return dal.GetUserProjectID(userid);
        }

        #endregion

        /// <summary>
        /// 获得技能组列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetSkillGroup()
        {
            return dal.GetSkillGroup();
        }
        /// <summary>
        /// 获取用户Email信息
        /// </summary>
        /// <returns></returns>
        public IList<string> GetUserEmail()
        {
            return dal.GetUserEmail();
        }

        /// <summary>
        /// 获得所有没有完成课程的学生邮件信息
        /// </summary>
        /// <returns></returns>
        public IList<SearchStudyLogModel> GetUnfinishUserCourseEmail()
        {
            return dal.GetUnfinishUserCourseEmail();
        }
    }
}
